package com.java.imauoj.sercive;

import com.java.imauoj.mapper.UserMapper;
import com.java.imauoj.moudel.FanHuiZhi;
import com.java.imauoj.moudel.Role;
import com.java.imauoj.moudel.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserMapper mapper;

    public List<User> getUserList(FanHuiZhi fhz){
        String sql = fhz.getSql();
        String[] sz = fhz.getFhz();
        List<User> list = mapper.getUserList(sql,sz);
        return list;
    }

    public User updateUser(User user){
        mapper.updateUser(user);
        User user1 = mapper.getUserOperate(user.getUser_id());
        return user1;
    }

    public User addUser(User user){
        mapper.addUser(user);
        User user1 = mapper.getUserOperate(user.getUser_id());
        return user1;
    }

    public User deleteUser(int user_id){
        User user1 = mapper.getUserOperate(user_id);
        mapper.deleteUser(user_id);
        return user1;
    }

}
